import React,{ PureComponent } from 'react';
import {Col,Form,Input} from 'antd';
import ProTypes from 'prop-types';
class AutoCreateInputItem extends PureComponent {


    render() {
      const {
        form: { getFieldDecorator },
      } = this.props;
      return this.props.data.map((item,index)=>(
          
       item.rules===false? <Col span={item.num}>
        <Form.Item label={<span>{item.name}</span>}> {
            getFieldDecorator(item.code)(<Input placeholder={item.placeholder} />)
        } </Form.Item >
        </Col>
        :
        <Col span={item.num}>
        <Form.Item label={<span>{item.name}</span>}> {
            getFieldDecorator(item.code,{
                rules: [{ whitespace: true, message: item.message,required: true, }],
            })(<Input placeholder={item.placeholder} />)
        } </Form.Item >
        </Col>

      ))
    }
  }
  // function AutoCreateInputItem(props){
  //   const { getFieldDecorator } = props.form;
  //   console.log(props)
  //   return props.data.map((item,index)=>(
          
  //       item.rules? <Col span={item.num}>
  //        <Form.Item label={<span>{item.name}</span>}> {
  //            getFieldDecorator(item.code)(<Input placeholder={item.placeholder} />)
  //        } </Form.Item >
  //        </Col>
  //        :
  //        <Col span={item.num}>
  //        <Form.Item label={<span>{item.name}</span>}> {
  //            getFieldDecorator(item.code,{
  //                rules: [{ whitespace: true, message: item.message,required: true, }],
  //            })(<Input placeholder={item.placeholder} />)
  //        } </Form.Item >
  //        </Col>
 
  //      ))
  // }
AutoCreateInputItem.ProTypes={
    data:ProTypes.object,
    form: ProTypes.object,
}
  export default Form.create()(AutoCreateInputItem)